package package02;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description throws 处理异常, 跟在方法声明后面，还是要try-catch处理
 * @Author zzj
 * @Date 2020/7/15 18:21
 */
public class ExceptionDemo06 {
    public static void main(String[] args) {
        // 调用者来处理异常
        try {
            strToDate();
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    public static Date strToDate() throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String s = "2019-01-01 12:21:11";
        Date date = sdf.parse(s);
        return date;
    }
}
